from rest_framework.generics import ListCreateAPIView
from rest_framework.viewsets import ModelViewSet, ReadOnlyModelViewSet

from .models import Material, User, Supplyer, ReceiveRecords, Processor, WorkShop, RepertoryRecords, PayRecords, \
    BuyRecords, ReturnGoodsRecords
from .serializers import MaterialSerializers, UserSerializers, SupplyerSerializers, ReceiveRecordsSerializers, \
    ProcessorSerializers, WorkShopSerializers, RepertoryRecordsSerializers, PayRecordsSerializers, \
    BuyRecordsSerializers, ReturnGoodsRecordsSerializers


# class MaterialList(ListCreateAPIView):
#     queryset = Material.objects.all()
#     serializer_class = MaterialSerializers


#继承法自ModelViewSet可以进行crud所有操作
class MaterialViewSet(ModelViewSet):
    queryset = Material.get_all()
    serializer_class = MaterialSerializers

#用户
class UserViewSet(ReadOnlyModelViewSet):
    queryset = User.get_all()
    serializer_class = UserSerializers

#供应商
class SupplyerViewSet(ModelViewSet):
    queryset = Supplyer.get_all()
    serializer_class = SupplyerSerializers

#加工商
class ProcessorViewSet(ModelViewSet):
    queryset = Processor.get_all()
    serializer_class = ProcessorSerializers

#车间
class WorkShopViewSet(ModelViewSet):
    queryset = WorkShop.get_all()
    serializer_class = WorkShopSerializers

#领用记录
class ReceiveRecordsViewSet(ModelViewSet):
    queryset = ReceiveRecords.get_all()
    serializer_class = ReceiveRecordsSerializers

#入库记录
class RepertoryRecordsViewSet(ModelViewSet):
    queryset=RepertoryRecords.get_all()
    serializer_class = RepertoryRecordsSerializers


#付款记录
class PayRecordsViewSet(ModelViewSet):
    queryset = PayRecords.get_all()
    serializer_class = PayRecordsSerializers


#采购记录
class BuyRecordsViewSet(ModelViewSet):
    queryset = BuyRecords.get_all()
    serializer_class = BuyRecordsSerializers

#退货记录
class ReturnGoodsRecordsViewSet(ModelViewSet):
    queryset = ReturnGoodsRecords.get_all()
    serializer_class = ReturnGoodsRecordsSerializers

